﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsApplication1
{
    public abstract class Hands
    {
        protected List<Card> hands;
        private int aceCount;
        private int total;

        public int AceCount
        {
            get { return aceCount; }
            set { aceCount = value; }
        }

        public int Total
        {
            get { return total; }
            set { total = value; }
        }

        public int Count
        {
            get
            {
                return hands.Count;
            }
        }

        public virtual void Add(Card cardToAdd)
        {
            hands.Add(cardToAdd);
        }
        public virtual Card Peek(int cardNumber)
        {
            return hands[cardNumber];
        }
        public virtual void Clear()
        {
            hands.Clear();
        }

        public virtual bool CheckBlackJack()
        {
            bool BlackJack = false;
            if (((this.Peek(0).Value == 1) && (this.Peek(1).Value >= 10)) || ((this.Peek(0).Value >= 10) && (this.Peek(1).Value == 1)))
            {
                BlackJack = true;
            }
            return BlackJack;
        }

        public virtual void CheckInitialAces()
        {
            //Check for Aces       
            if (this.Peek(0).Value == 1)
            {
                this.AceCount++;
            }
            if (this.Peek(1).Value == 1)
            {
                this.AceCount++;
            }
        }

        //Adjust for soft aces if applicable
        public virtual void Over21WithAce()
        {
            this.AceCount--;
            this.Total = this.Total - 10;
        }

        public virtual void CheckNewAce()
        {
            if (this.Peek(hands.Count - 1).Value == 1)
            {
                this.AceCount++;
                this.Total += 10;
            }
        }
    }
}
